package com.tuonbed.qrqd;

import com.google.zxing.WriterException;

import java.io.*;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;

/**
 *
 */
public class MainOP {

    private static Map<String,String> data=new HashMap();

    public static void main(String args[]) {
        System.out.println(PROPARAM.OUT_DIR);
        initData();
        try {
            for (String tip : data.keySet()) {
                QRCodeMaker.MakeQrCodeWithLogo(data.get(tip), PROPARAM.OUT_DIR + tip + ".jpg",PROPARAM.LOGO_PATH);
            }
            PdfUtil.imagesToPdf(PROPARAM.CODE_START+"-"+PROPARAM.CODE_END,PROPARAM.OUT_DIR);
            PdfUtil.deleteFiles(PROPARAM.OUT_DIR);
        } catch (WriterException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void initData() {
        DecimalFormat df=new DecimalFormat(PROPARAM.FORMAT);
        for (int i = PROPARAM.CODE_START; i <= PROPARAM.CODE_END; i++) {
            data.put(df.format(i), PROPARAM.INFO + df.format(i));
        }
    }


}
